/// Department 部门
/// 可以用于保存网络请求的json对象转换
/// 可以用于树形展示的构造数据
class Department {
  int id;
  String coding;
  String name;
  int parentId;
  List<Department> children;
  int deptId;
  String channel;
  String url;
  String cameraType;

  ///
  /// 构造函数
  ///
  Department(
      {this.id,
      this.coding,
      this.name,
      this.parentId,
      this.children,
      this.deptId,
      this.channel,
      this.url,
      this.cameraType});

  ///
  /// 将json对象转化为Department对象
  /// @param json 有department对象结构的json对象
  ///
  Department.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    coding = json['coding'];
    name = json['name'];
    parentId = json['parentId'];
    if (json['children'] != null) {
      children = <Department>[];
      json['children'].forEach((v) {
        children.add(new Department.fromJson(v));
      });
    }
    deptId = json['deptId'];
    channel = json['channel'];
    url = json['url'];
    cameraType = json['cameraType'];
  }

  ///
  /// 将Department转化为对应的json
  /// @returns json对象
  ///
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['coding'] = this.coding;
    data['name'] = this.name;
    data['parentId'] = this.parentId;
    if (this.children != null) {
      data['children'] = this.children.map((v) => v.toJson()).toList();
    }
    data['deptId'] = this.deptId;
    data['channel'] = this.channel;
    data['url'] = this.url;
    data['cameraType'] = this.cameraType;
    return data;
  }
}
